'use strict';

const BaseService = require('./base');

class AccountLogService extends BaseService {
    async addLog(logInfo) {
        return new Promise(async (reslove, reject) => {
            let model = new this.ctx.model.AccountLog(logInfo);
            await model.save((err, res) => {
                if (err) {
                    reject(err);
                } else {
                    reslove(res);
                }
            });
        });
    }

    /**
     * 查询用户账户日志
     * @param {*} uId 
     */
    async queryUserLog(uId) {
        return new Promise(async (reslove, reject) => {
            await this.ctx.model.AccountLog.find({
                uId
            }, (err, res) => {
                if (err) {
                    reject(err);
                } else {
                    reslove(res);
                }
            });
        });
    }
}

module.exports = AccountLogService;
